home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / Triton / Source / classes / line.c < prev    next >
C/C++ Source or Header  |  1998-05-23  |  6KB  |  178 lines

  1. /*
  2.  *  OpenTriton -- A free release of the triton.library source code
  3.  *  Copyright (C) 1993-1998  Stefan Zeiger
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20.  
  21.  
  22. /****** triton.library/class_Line ******
  23. *
  24. *   NAME    
  25. *    class_Line -- A 3D line
  26. *
  27. *   SUPERCLASS
  28. *    class_DisplayObject
  29. *
  30. *   SYNOPSIS
  31. *    TROB_Line
  32. *
  33. *   ATTRIBUTES
  34. *    <Default>        : ULONG flags
  35. *                       - TROF_HORIZ        : Horizontal line
  36. *                                             (Overrides group dimension)
  37. *                       - TROF_VERT         : Vertical line
  38. *                                             (Overrides group dimension)
  39. *                       - TROF_RAISED       : Raised line
  40. *                       [create]
  41. *
  42. ******/
  43.  
  44.  
  45. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  46. //////////////////////////////////////////////////////////////////////////////////////// Include our stuff //
  47. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48.  
  49. #define TR_THIS_IS_TRITON
  50.  
  51. #include <libraries/triton.h>
  52. #include <clib/triton_protos.h>
  53. #include "/internal.h"
  54. #include "line.def"
  55.  
  56.  
  57. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  58. ////////////////////////////////////////////////////////////////////////////////////////////// Object data //
  59. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60.  
  61. #define OBJECT (&(object->DO.O))
  62. #define DISPLAYOBJECT (&(object->DO))
  63. #define LINE object
  64.  
  65.  
  66. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  67. ////////////////////////////////////////////////////////////////////////////////////////////////// Methods //
  68. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  69.  
  70. TR_METHOD(Line,NEW,NewData)
  71. {
  72.   if(!TRDP_DisplayObject_NEW(object,messageid,data,metaclass->trc_SuperClass)) return NULL;
  73.   DISPLAYOBJECT->MinWidth=TR_ThickBorders(data->project)?4:2;
  74.   DISPLAYOBJECT->MinHeight=2;
  75.  
  76.   LINE->Flags=data->itemdata;
  77.  
  78.   if(!(LINE->Flags&(TROF_VERT|TROF_HORIZ)))
  79.     {
  80.       if((data->grouptype)==TRGR_Horiz) LINE->Flags=TROF_VERT;
  81.       if((data->grouptype)==TRGR_Vert) LINE->Flags=TROF_HORIZ;
  82.     }
  83.  
  84.   if(LINE->Flags&TROF_HORIZ)
  85.     {
  86.       DISPLAYOBJECT->XResize=TRUE;
  87.       DISPLAYOBJECT->MinWidth=data->project->trp_PropFont->tf_YSize;
  88.     }
  89.   else
  90.     {
  91.       DISPLAYOBJECT->YResize=TRUE;
  92.       DISPLAYOBJECT->MinHeight=data->project->trp_PropFont->tf_YSize;
  93.     }
  94.  
  95.   return (ULONG)object;
  96. }
  97.  
  98.  
  99. TR_SIMPLEMETHOD(Line,INSTALL_REFRESH)
  100. {
  101.   struct TR_Project *project;
  102.   ULONG left,top,width,height;
  103.   UWORD firstpen,secondpen;
  104.  
  105.   TR_SUPERMETHOD;
  106.   project=OBJECT->Project;
  107.  
  108.   left=DISPLAYOBJECT->Left;
  109.   top=DISPLAYOBJECT->Top;
  110.   width=DISPLAYOBJECT->Width;
  111.   height=DISPLAYOBJECT->Height;
  112.  
  113.   if(LINE->Flags&TROF_RAISED)
  114.     {
  115.       firstpen=project->trp_DrawInfo->dri_Pens[SHINEPEN];
  116.       secondpen=project->trp_DrawInfo->dri_Pens[SHADOWPEN];
  117.     }
  118.   else
  119.     {
  120.       firstpen=project->trp_DrawInfo->dri_Pens[SHADOWPEN];
  121.       secondpen=project->trp_DrawInfo->dri_Pens[SHINEPEN];
  122.     }
  123.  
  124.   if(LINE->Flags&TROF_HORIZ)
  125.     {
  126.       SetAPen(project->trp_Window->RPort,firstpen);
  127.       Move(project->trp_Window->RPort,left,top);
  128.       Draw(project->trp_Window->RPort,left+width-1,top);
  129.       SetAPen(project->trp_Window->RPort,secondpen);
  130.       Move(project->trp_Window->RPort,left,top+1);
  131.       Draw(project->trp_Window->RPort,left+width-1,top+1);
  132.       //--if(LINE->Flags&TRLI_3DSIDES)
  133.         //--{
  134.       Draw(project->trp_Window->RPort,left+width-1,top);
  135.       SetAPen(project->trp_Window->RPort,firstpen);
  136.           Move(project->trp_Window->RPort,left,top);
  137.           Draw(project->trp_Window->RPort,left,top+1);
  138.     //--}
  139.     }
  140.   else /* Vertical */
  141.     {
  142.       SetAPen(project->trp_Window->RPort,firstpen);
  143.       Move(project->trp_Window->RPort,left,top);
  144.       Draw(project->trp_Window->RPort,left,top+height-1);
  145.       if(TR_ThickBorders(project))
  146.         {
  147.           Move(project->trp_Window->RPort,left+1,top);
  148.           Draw(project->trp_Window->RPort,left+1,top+height-1);
  149.           SetAPen(project->trp_Window->RPort,secondpen);
  150.           Move(project->trp_Window->RPort,left+2,top);
  151.           Draw(project->trp_Window->RPort,left+2,top+height-1);
  152.           Move(project->trp_Window->RPort,left+3,top);
  153.           Draw(project->trp_Window->RPort,left+3,top+height-1);
  154.           //--if(LINE->Flags&TRLI_3DSIDES)
  155.       //--{
  156.             Draw(project->trp_Window->RPort,left+1,top+height-1);
  157.             SetAPen(project->trp_Window->RPort,firstpen);
  158.             Move(project->trp_Window->RPort,left+1,top);
  159.             Draw(project->trp_Window->RPort,left+2,top);
  160.           //--}
  161.         }
  162.       else
  163.         {
  164.           SetAPen(project->trp_Window->RPort,secondpen);
  165.           Move(project->trp_Window->RPort,left+1,top);
  166.           Draw(project->trp_Window->RPort,left+1,top+height-1);
  167.           //--if(LINE->Flags&TRLI_3DSIDES)
  168.           //--{
  169.             Draw(project->trp_Window->RPort,left,top+height-1);
  170.             SetAPen(project->trp_Window->RPort,firstpen);
  171.             Move(project->trp_Window->RPort,left,top);
  172.             Draw(project->trp_Window->RPort,left+1,top);
  173.           //--}
  174.         }
  175.     }
  176.   return 1L;
  177. }
  178.